﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ewk.Extensions.UnitTests.StringExtensionsTests
{
    [TestClass]
    public class IsNumericTests
    {
        [TestMethod]
        public void IsNumeric_must_return_true_when_the_string_consists_of_only_numerical_characters()
        {
            const string testString = "234256767586796907675875634523433244345111123445456456567670987654321";
            Assert.IsTrue(testString.IsNumeric());

            for (var i = 48; i < 58; i++)
            {
                var testChar = char.ConvertFromUtf32(i);
                Assert.IsTrue(testChar.IsNumeric(), string.Format("The conversion of {0} to a character didn't have the expeted result {1}.", i, testChar));
            }
        }

        [TestMethod]
        public void IsNumeric_must_return_false_when_the_string_contains_other_than_numerical_characters()
        {
            for (var i = 0; i < 48; i++)
            {
                var testChar = char.ConvertFromUtf32(i);
                Assert.IsFalse(testChar.IsNumeric(), string.Format("The conversion of {0} to a character didn't have the expeted result {1}.", i, testChar));
            }

            for (var i = 58; i < 1632; i++)
            {
                var testChar = char.ConvertFromUtf32(i);
                Assert.IsFalse(testChar.IsNumeric(), string.Format("The conversion of {0} to a character didn't have the expeted result {1}.", i, testChar));
            }
        }
    }
}